package cz.muni.fi.pa165.transfers;

import cz.muni.fi.pa165.dto.PackageDTO;
import cz.muni.fi.pa165.entity.Package;

/**
 * Class provides converting between Package entity and DTO
 * 
 * @author <a href="mailto:vramik at redhat.com">Vlastislav Ramik</a>
 */
public class PackageT {

    public static PackageDTO entityToDTO(Package pkg){
        if (pkg == null) {
            return null;
        }
        
        PackageDTO packageDTO = new PackageDTO();
        
        packageDTO.setHeight(pkg.getHeight());
        packageDTO.setId(pkg.getId());
        packageDTO.setPrice(pkg.getPrice());
        packageDTO.setWeight(pkg.getWeight());
        packageDTO.setWidth(pkg.getWidth());
                
        return packageDTO;        
    }
    
    public static Package dTOtoEntity(PackageDTO packageDTO){
        if (packageDTO == null) {
            return null;
        }
        
        Package pkg = new Package();
        
        pkg.setHeight(packageDTO.getHeight());
        pkg.setId(packageDTO.getId());
        pkg.setPrice(packageDTO.getPrice());
        pkg.setWeight(packageDTO.getWeight());
        pkg.setWidth(packageDTO.getWidth());
                
        return pkg;        
    }    
}
